{% extends 'TopxiaWebBundle:CourseManage:layout.html.twig' %}

{% block title %}{{'基本信息'|trans}} - {{ parent() }}{% endblock %}

{% set side_nav = 'base' %}
{% set script_controller = 'course-manage/base' %}
{%
  set script_arguments = {
    categoryUrl: path('category_all'),
    tagMatchUrl: path('tag_match'),
    locationUrl: path('location_all')
  }
%}
{% block main %}

<div class="panel panel-default panel-col">
  <div class="panel-heading">{{'基本信息'|trans}}</div>
  <div class="panel-body">
    <form class="form-horizontal" id="course-form" method="post">

      {{ web_macro.flash_messages() }}

      <div class="form-group">
        <label class="col-md-2 control-label">{{'标题'|trans}}</label>
        <div class="col-md-8 controls">
          <input type="text" id="course_title" name="title" required="required" class="form-control" value="{{ course.title|default('') }}">
          <div class="help-block" style="display:none;"></div>
        </div>
      </div>

      <div class="form-group">
        <label class="col-md-2 control-label">{{'副标题'|trans}}</label>
        <div class="col-md-8 controls">
          <textarea id="course_subtitle" name="subtitle" required="required" class="form-control">{{ course.subtitle|default('') }}</textarea>
          <div class="help-block" style="display:none;"></div>
        </div>
      </div>

      <div class="form-group">
        <label class="col-md-2 control-label">{{'标签'|trans}}</label>
        <div class="col-md-8 controls">
          <input type="text" id="course_tags" name="tags" required="required" class="width-full select2-offscreen" tabindex="-1" value="{{ tags|join(',') }}" data-explain="{{'用于按标签搜索课程、相关课程的提取等，由网校管理员后台统一管理'|trans}}">
          <div class="help-block">{{'用于按标签搜索课程、相关课程的提取等，由网校管理员后台统一管理'|trans}}</div>
        </div>
      </div>

        <div class="form-group">
        <label class="col-md-2 control-label">{{'课程购买'|trans}}</label>
          <div class="col-md-8 controls radios">
            {{ radios('buyable', {'1':'开启'|trans, '0':'关闭'|trans}, course.buyable|default(1) ) }}
           <div class="help-block">{{'关闭后课程将无法在线购买加入、由教师/管理员后台导入。'|trans}}</div>
        </div>
      </div>

      {% if course.type == 'live' %}

      <div class="form-group">
        <label class="col-md-2 control-label" for="maxStudentNum-field">直播最大{{setting('default.user_name')|default('学员')}}数</label>
        <div class="col-md-8 controls">
          <input type="text" id="maxStudentNum-field" name="maxStudentNum" class="form-control width-input width-input-large" value="{{ course.maxStudentNum|default(20) }}" data-live-capacity-url="{{path('live_capacity',{id:course.id})}}"> {{'人'|trans}}
          <div class="help-block" style="display:none;"></div>
        </div>
      </div>

      {% endif %}

      <div class="form-group">
        <label class="col-md-2 control-label" for="course_expiryDay">{% if setting('default.user_name') %}{{setting('default.user_name')|default('学员'|trans)}}{% else %}{{'学员'|trans}}{% endif %}{{'有效期'|trans}}</label>
        <div class="col-md-8 controls">
          <input type="text" id="course_expiryDay" name="expiryDay" required="required" class="form-control width-input width-input-large" value="{{ course.expiryDay }}" > {{'天'|trans}}
          <div class="help-block">设置该值后，{{setting('default.user_name', '学员')}}只能在有效期内进行课程的相关操作，系统默认会在到期前10天提醒{{setting('default.user_name', '学员')}}。该值为0，则不做此限制。</div>
        </div>
      </div>

      {% if course.type == 'normal' %}
        <div class="form-group">
          <label class="col-md-2 control-label">{{'连载状态'|trans}}</label>
          <div class="col-md-8 controls radios">
            {{ radios('serializeMode', {'none':'非连载课程'|trans, 'serialize':'更新中'|trans, 'finished':'已完结'|trans}, course.serializeMode|default('none') ) }}
          </div>
        </div>
      {% endif %}

      {% if setting('magic.lesson_watch_limit') %}
        <div class="form-group">
          <label class="col-md-2 control-label">{{'视频观看时间限制'|trans}}</label>
          <div class="col-md-8 controls">
            <input type="text" id="course_expiryDay" name="watchLimit" required="required" class="form-control width-input width-input-large" value="{{ course.watchLimit }}" > 倍单视频总时长
            <div class="help-block">{{'0表示不限制。'|trans}}</div>
          </div>
        </div>
      {% endif %}

      {% if setting('magic.buy_before_approval') %}
        <div class="form-group">
          <label class="col-md-2 control-label">{{'实名认证'|trans}}</label>
          <div class="col-md-8 controls radios">
            {{ radios('approval', {'1':'是'|trans, '0':'否'|trans}, course.approval ) }}
            <div class="help-block">{{'设置该值后，学员购买课程前，必须先去申请实名认证。'|trans}}</div>
          </div>
        </div>
      {% endif %}

      <div class="form-group">
        <label class="col-md-2 control-label">{{'分类'|trans}}</label>
        <div class="col-md-8 controls">
          <select id="course_categoryId" name="categoryId" required="required" class="form-control width-input width-input-large">
            {{ select_options(category_choices('course'), course.categoryId, '分类'|trans) }}
          </select>
          <div class="help-block" style="display:none;"></div>
        </div>
      </div>
      
      {% include 'OrgBundle:Org:org-tree-select.html.twig' with {orgCode : course.orgCode, inputClass: 'width-input width-input-large'} %}

      {% if course.type == 'live'%}
      <div id="live-plugin-url" class="form-group hidden">
          <div class="col-md-offset-2 col-md-8 controls">
            <a  href="" target="_blank">{{'直播“桌面分享”插件下载'|trans}}</a>
          </div>
      </div>
      {% endif %}
      <div class="form-group">
        <div class="col-md-offset-2 col-md-8 controls">
            <button class="btn btn-fat btn-primary" id="course-create-btn" type="submit">{{'保存'|trans}}</button>
        </div>
      </div>

      <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

    </form>
  </div>
</div>

{% endblock %}



